import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//引入图片样式
import './assets/font/iconfont.css' 

// 引入element-ui
import ElementUI, { Loading } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
// 引入axios
import axios from 'axios';
axios.defaults.baseURL="http://121.41.51.231:5000/api/private/v1/";

// axios拦截器
// 每次发请求之前都会触发
axios.interceptors.request.use((config)=>{
  // 请求之前设置加载框
 Loading.service();
  config.headers.Authorization=sessionStorage.getItem("token");
  return config;
})

// 每次发请求之后都会触发
axios.interceptors.response.use((config)=>{
  if(config.data.meta.status==200 || config.data.meta.status==201){
    
  }else{
    router.push("/login");
  }
  // 请求之后关闭加载框
  Loading.service().close();
  return config;
})

Vue.prototype.axios=axios;

// import axios1 from 'axios';
// axios1.defaults.baseURL="http://121.41.51.231:5000/api/private/v1/";
// Vue.prototype.axios1=axios1;

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
